package com.zf.shuashua.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class SquareLayout16_9 extends FrameLayout {
    public SquareLayout16_9(@NonNull Context context) {
        super(context);
    }

    public SquareLayout16_9(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int widthSize = MeasureSpec.getSize(widthMeasureSpec);
        final int newMeasureSpec = MeasureSpec.makeMeasureSpec((int) (widthSize * 9F / 16F), MeasureSpec.EXACTLY);
        super.onMeasure(widthMeasureSpec, newMeasureSpec);
    }
}
